﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using System.Text;
using Microsoft.Extensions.Options;
using MySql.Data.MySqlClient;
using OAuth.Dapper.Common;
using OAuth.Dapper.Infrastructure.Data;

namespace OAuth.Common.Dapper
{
    public class BaseDbConfig : DapperDBContext
    {
        public BaseDbConfig(IOptions<DapperDBContextOptions> optionsAccessor) : base(optionsAccessor)
        {
        }


        protected override IDbConnection CreateConnection(string connectionString, string dbType)
        {
            IDbConnection conn = null;
            var connectioonType = dbType.ToUpper();

            if (connectioonType == ConnectionType.MYSQL.ToString())
            {


                conn = new MySqlConnection(connectionString);
            }
            if (connectioonType == ConnectionType.SQLSERVICE.ToString())
            {
                conn = new SqlConnection(connectionString);
            }
            return conn;
        }
    }
}
